#include <stdio.h>

void find_two_largest(const int *a, int n, int *largest, int *second_largest);

int main(void)
{
    int a[5] = {1, 2, 3, 8, 5};
    const int *p;
    int n = 5;
    int largest, second_largest;

    p = a;
    find_two_largest(p, n, &largest, &second_largest);

    printf("%d\n", largest);
    printf("%d\n", second_largest);
}

void find_two_largest(const int *a, int n, int *largest, int *second_largest)
{
    *largest = *a;
    *second_largest = *(a + 1);

    for (int i = 1; i < n; i++)
    {
        if (*(a + i) > *largest)
        {
            *second_largest = *largest;
            *largest = *(a + i);
        }
        if (*(a + i) > *second_largest && *(a + i) != *largest)
            *second_largest = *(a + i);
    }
}